import { ApiBase, Route, src, resHtml, valid } from 'koacat'
import { App, Ctx } from '../../app'

//挂载页面
export class ManageApi extends ApiBase<App, Ctx> {
  constructor(app: App) {
    super(app)
    app.vite.include('department', src('/services/manage/department.vue'))
    app.vite.include('job', src('/services/manage/job.vue'))
    app.vite.include('user', src('/services/manage/user.vue'))
    app.vite.include('role', src('/services/manage/role.vue'))
  }

  public routes: Route<Ctx>[] = [ {
    tags: ['view'],
    path: '/manage/department',
    middlewares: [],
    get: async (ctx: Ctx) => resHtml(ctx, await this.app.vite.render('department', {}, '部门管理'))
  }, {
    tags: ['view'],
    path: '/manage/job',
    middlewares: [],
    get: async (ctx: Ctx) => resHtml(ctx, await this.app.vite.render('job', {}, '岗位管理'))
  },{
    tags: ['view'],
    path: '/manage/user',
    middlewares: [],
    get: async (ctx: Ctx) => resHtml(ctx, await this.app.vite.render('user', {}, '用户管理'))
  }, {
    tags: ['view'],
    path: '/manage/role',
    middlewares: [],
    get: async (ctx: Ctx) => resHtml(ctx, await this.app.vite.render('role', {}, '角色管理'))
  }]
}
